package jtg.junit;

import jtg.generator.BaseGenerator;
import jtg.generator.DealSolution;
import soot.Local;

import java.util.ArrayList;
import java.util.List;

public class JunitGenerateUtil {
    /**
     * 只针对一个参数的函数的从头生成测试用例和junit代码
     * @param generator
     * @throws Exception
     */
    public static void generateToJunit(BaseGenerator generator) throws Exception {
        String clsName = generator.getClsName();
        String mtdName = generator.getMtdName();
        // 获取生成的testset
        List<String> testset = generator.generate();
        // 把多个String写的testInput转换为具体的Object
        List<Local> localPara = generator.getLocalPara();
        List<Object> testSetObj = DealSolution.dealSolution2Object(testset, localPara);
        JunitGeneratorNoAssert.JunitGenerateMul(clsName, mtdName, testSetObj);
    }
}
